---
title: "Analysis Script (Merged Receivers 1 & 2)"
author: "Martin Naunov"
date: "13/08/2024"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE,message=FALSE)
setwd("/Users/martinnaunov/Desktop/Desktop - Martin’s MacBook Pro (2)/Persuasion/2_workingdata")
```

```{r, include=FALSE}
library(dplyr)
library(data.table) 
library(modelsummary)
library(gridExtra)
library(ggplot2)
library(grid)
library(lme4)
library(lmerTest)
library(stargazer) 
library(marginaleffects)
library(psych)

rm(list=ls())
```


```{r}
setwd("/Users/martinnaunov/Desktop/Desktop - Martin’s MacBook Pro (2)/Persuasion/2_workingdata")
library(dplyr)

data_sr1 <- read.csv("working_data_final_sr1_v2.csv") %>% 
  dplyr::select(pre, post, side, quarkelt1, quarkelt2, respid, respondent,
                partyid_7, issue, affpol, att_strength, pol_intr_full, pol_intr, 
                pol_know_avg, persp_tak, nfc, self_est, female, race, edu, 
                income, age, mlengthwords, mlengthchar, time, common_ground, 
                personal_rev, specific_fact, respondent, 
                task_persuade, task_expect, movement, binary) %>% 
  mutate_at(vars(pre, post, quarkelt1, quarkelt2, partyid_7, affpol, 
                 att_strength, pol_intr_full, pol_intr, pol_know_avg, 
                 persp_tak, nfc,  self_est, income, age, mlengthwords, 
                 mlengthchar, time, task_persuade),
            .funs = as.numeric) %>% 
  mutate_at(vars(side, respid, respondent, 
                 issue, female, race, edu, common_ground,
                 personal_rev, specific_fact, task_expect, movement, binary), .funs = as.factor)

data_sr1$anchor <- 1
data_sr1$anchor <- as.factor(data_sr1$anchor)

data_sr2 <- read.csv("working_data_final_sr2.csv") %>% 
  dplyr::select(pre, post, side, quarkelt1, quarkelt2, respid, respondent,
                partyid_7, issue, affpol, att_strength, pol_intr_full, pol_intr, 
                pol_know_avg, persp_tak, nfc, self_est, female, race, edu, 
                income, age, mlengthwords, mlengthchar, time, common_ground, 
               personal_rev, specific_fact, respondent, 
                task_persuade, task_expect, movement, binary, partyid_7_rec,edu_rec,age_rec,income_rec,race_rec, female_main, female_alt, anchor, controlcond) %>% 
  mutate_at(vars(pre, post, quarkelt1, quarkelt2, partyid_7, partyid_7_rec, affpol, 
                 att_strength, pol_intr_full, pol_intr, pol_know_avg, 
                 persp_tak, nfc,  self_est, income, age, mlengthwords, 
                 mlengthchar, time, task_persuade, age_rec, income_rec),
            .funs = as.numeric) %>% 
  mutate_at(vars(side, respid, respondent, 
                 issue, female, race, edu, race_rec, edu_rec, female_main, female_alt, common_ground,
                 personal_rev, specific_fact, task_expect, movement, binary, anchor, controlcond,), .funs = as.factor)

#Remove control

data_sr2 <- subset(data_sr2, controlcond != 1)

#Adding 5000 to respondent so that we effectively can differentiate between R1 and R2 respondents
data_sr2$respondent <- as.numeric(data_sr2$respondent)
data_sr2$respondent <- data_sr2$respondent + 5000 
data_sr2$respondent <- as.factor(data_sr2$respondent)
```

```{r}
merged_data <- bind_rows(data_sr1, data_sr2)
df2 <- merged_data
```


```{r}

df2 <-df2 %>% 
  mutate(change2 = quarkelt2 - quarkelt1)

# Plot by issue side
df2 <- df2 %>% 
  group_by(side)

# Recode the side variable for graphing
df2$side <- factor(df2$side, levels = c("env_cons", "imm_cons", "trans_cons", 
                             "env_lib", "imm_lib", "trans_lib"))
# Change side labels for title in graphs
df2$side <- recode(df2$side, 
                  "env_cons" = "Conservative Energy",
                  "imm_cons" = "Conservative Immigration", 
                  "trans_cons" = "Conservative Transgender", 
                  "env_lib" = "Liberal Energy", 
                  "imm_lib" = "Liberal Immigration", 
                  "trans_lib" = "Liberal Transgender")

plot1 <- by(df2, df2$side, function(sub){
  ggplot(sub, aes(change2)) +
        geom_histogram(aes(y = (..count..)/sum(..count..)),
                   color="black", fill="gray", bins = 20) +
        ggtitle(sub$side[[1]]) + 
    scale_x_continuous(breaks = seq(-10, 10 , 5), 
                       limits = c(-10.5, 10.5)) + 
    scale_y_continuous(labels = scales::percent, 
                       breaks = seq(0,.8, .2), 
                       limits = c(-0.05, .70)) + 
  theme_bw() + 
  theme(plot.title = element_text(hjust = 0.5, size = 9, face = "bold") , 
          axis.title.x = element_blank(), 
          axis.title.y = element_blank())
  })

plot1 <- grid.arrange(arrangeGrob(grobs = plot1, ncol = 3, 
                         bottom = textGrob("Persuasion",
                                           gp = gpar(fontsize = 10,
                                                     fontface = "bold")),
                         left = textGrob("Percent",
                                         rot = 90,
                                         gp = gpar(fontsize = 10, 
                                                   fontface = "bold")),
                         ))

```


### Range Standardize Variables
```{r}
range01 <- function(x, ...){(x - min(x, ...)) / (max(x, ...) - min(x, ...))}

# Note that political knowledge and interest already vary between 0 and 1.
df2$affpol <- range01(df2$affpol, na.rm = T)
df2$att_strength <- range01(df2$att_strength, na.rm = T)
df2$persp_tak <- range01(df2$persp_tak, na.rm = T)
df2$nfc <- range01(df2$nfc, na.rm = T)
df2$self_est <- range01(df2$self_est, na.rm = T)
df2$mlengthwords <- range01(df2$mlengthwords, na.rm = T)
df2$mlengthchar <- range01(df2$mlengthchar, na.rm = T)
df2$time <- range01(df2$time, na.rm = T)
df2$age <- range01(df2$age, na.rm = T)
df2$income <- range01(df2$income, na.rm = T)
```


## Main Analysis: Sender Characteristics

```{r}
df2$movement_3 <- df2$movement
df2$movement_3 <- as.ordered(df2$movement_3)
```

## Party ID Intensity
```{r}
### Make a new variable called partyid_cat where a 1 indicates a pure independent
### (4 in partyid_7), 2 indicates a leaner (5 and 3 in partyid_7), 3 indicates 
### a not strong partisan (6 and 2 in partyid_7) and 4 indicates a strong partisan
### (7 and 1 in partyid_7)

df2$partyid_cat <- NA

df2$partyid_cat[df2$partyid_7 == 4] <- 1
df2$partyid_cat[df2$partyid_7 == 3 | df2$partyid_7 == 5] <- 2
df2$partyid_cat[df2$partyid_7 == 2 | df2$partyid_7 == 6] <- 3
df2$partyid_cat[df2$partyid_7 == 1 | df2$partyid_7 == 7] <- 4

df2$partyid_cat <- as.factor(df2$partyid_cat)
```



# Conditioned by Issue

### APPENDIX (CONDITIONED BY ISSUE)

```{r}
df_env <- subset(df2, issue == "env")
df_imm <- subset(df2, issue == "imm")
df_trans <- subset(df2, issue == "trans")
```



#H1: Need for cognition is associated with greater persuasion
```{r}
#Issue: Environment
fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_env)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df_env[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_estimation_3)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.02138207


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.02138207,]

summary(lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_reduced_nfc))

#nfc         3.409e-01  1.096e-01 9.154e+01   3.111  0.00249 ** 

#p=0.001245 (0.00249/2)
```


```{r}
#Issue: Immigration

fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_imm)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df_imm[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_estimation_3)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.03043042


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.03043042,]

summary(lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_reduced_nfc))

#nfc         4.521e-02  1.163e-01 1.144e+02   0.389   0.6982
    
#p=0.3491
```

```{r}
#Issue: Transgender

fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_trans)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df_trans[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_estimation_3)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.0180589


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.0180589,]

summary(lmer(quarkelt2 ~ quarkelt1 + nfc + anchor +
                           (1|respid), data = df_reduced_nfc))


#nfc         1.039e-01  1.514e-01 9.993e+01   0.686   0.4943  

#p=0.24715
```


# H2: Perspective taking ability is associated with greater persuasion

#Environment
```{r}
library(lmerTest)

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_env)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df_env[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.02215547

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.02215547,]

summary(lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_reduced_persptak))

#persp_tak   2.445e-01  1.243e-01 8.285e+01   1.967   0.0525 .

#p=0.02625
```

#Immigration
```{r}
library(lmerTest)
### Perspective Taking ###

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_imm)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df_imm[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.02983081

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.02983081,]

summary(lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_reduced_persptak))

#persp_tak   1.896e-01  1.316e-01 9.333e+01   1.440    0.153    

#p=0.0765

```

#Transgender
```{r}
library(lmerTest)

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_trans)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df_trans[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.01786357

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.01786357,]

summary(lmer(quarkelt2 ~ quarkelt1 + persp_tak + anchor +
                           (1|respid), data = df_reduced_persptak))

#persp_tak   3.698e-02  1.638e-01 1.036e+02   0.226   0.8218    
  

#p=0.4109

```

# H3: Senders who use personal appeals are more persuasive

#Environment
```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_env) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df_env[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor + (1|respid), data = df_estimation_9)

summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.01969554

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.01969554,]


summary(lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_reduced_personal_rev))

#personal_rev1    0.31974    0.15956   91.24884   2.004    0.048 *

#p=0.024
```

#Immigration
```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_imm) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df_imm[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor + (1|respid), data = df_estimation_9)

summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.02556705

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.02556705,]


summary(lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_reduced_personal_rev))

#personal_rev1 3.734e-01  8.856e-02 1.374e+02   4.216 4.48e-05 ***

```

#Trans
```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_trans) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df_trans[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor + (1|respid), data = df_estimation_9)

summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.01782435

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.01782435,]


summary(lmer(quarkelt2 ~ quarkelt1 + personal_rev + anchor +
                           (1|respid), data = df_reduced_personal_rev))

#personal_rev1 -7.624e-03  9.549e-02  1.096e+02   -0.08    0.937  
   

#p=0.4685
```


# H4: Senders who highlight common ground are more persuasive

#Environment
```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor + (1|respid), data = df_env)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df_env[as.numeric(rownames(cooks_h10)), ]


fit_cg_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_estimation_10)
summary(fit_cg_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_cg_est))


mean(cooks_h10$`cooks.distance(fit_cg_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_cg_est)`)
#0.02124364

df_reduced_cg <- df_estimation_10[cooks_h10$`cooks.distance(fit_cg_est)` < 0.02124364,]


summary(lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_reduced_cg))

#common_ground1  2.033e-01  6.269e-02  8.062e+01   3.243  0.00172 ** 


#p=0.00086
```

#Immigration
```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor + (1|respid), data = df_imm)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df_imm[as.numeric(rownames(cooks_h10)), ]


fit_cg_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_estimation_10)
summary(fit_cg_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_cg_est))


mean(cooks_h10$`cooks.distance(fit_cg_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_cg_est)`)
#0.0287323

df_reduced_cg <- df_estimation_10[cooks_h10$`cooks.distance(fit_cg_est)` < 0.0287323,]


summary(lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_reduced_cg))

#common_ground1 2.072e-01  6.867e-02 1.114e+02   3.017  0.00317 ** 


#p=0.001585
```

#Trans

```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor + (1|respid), data = df_trans)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df_trans[as.numeric(rownames(cooks_h10)), ]


fit_cg_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_estimation_10)
summary(fit_cg_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_cg_est))


mean(cooks_h10$`cooks.distance(fit_cg_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_cg_est)`)
#0.01676173

df_reduced_cg <- df_estimation_10[cooks_h10$`cooks.distance(fit_cg_est)` < 0.01676173,]


summary(lmer(quarkelt2 ~ quarkelt1 + common_ground + anchor +
                           (1|respid), data = df_reduced_cg))

#common_ground1 1.696e-01  7.069e-02 1.012e+02   2.399   0.0183 * 
 
#p=0.00915
```

# H5: Long messages are more persuasive

#Environment
```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords +  anchor +
                           (1|respid), data = df_env)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df_env[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.01911626

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.01911626,]


summary(lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_reduced_length))

#mlengthwords  3.994e-01  1.409e-01  1.166e+02   2.834  0.00542 **

#p=0.00271
```

#Immigration
```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords +  anchor +
                           (1|respid), data = df_imm)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df_imm[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.02182612

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.02182612,]


summary(lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_reduced_length))

#mlengthwords 5.911e-01  1.326e-01 1.143e+02   4.459 1.93e-05 ***

```

#Trans
```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords +  anchor +
                           (1|respid), data = df_trans)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df_trans[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.01767499

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.01767499,]


summary(lmer(quarkelt2 ~ quarkelt1 + mlengthwords + anchor +
                           (1|respid), data = df_reduced_length))

#mlengthwords 2.647e-01  1.616e-01 1.007e+02   1.638  0.10449    

#p=0.052245
```



# H6: Messages that took more time to write are more persuasive

#Environment
```{r}

# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_env)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df_env[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.02328045

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.02328045,]


summary(lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_reduced_time))

#time        1.939e-01  1.676e-01 8.261e+01   1.157    0.251    
 
#p=0.1255

```

#Immigration
```{r}

# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_imm)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df_imm[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.0265161

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.0265161,]


summary(lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_reduced_time))

#time        5.533e-01  1.860e-01 1.317e+02   2.975  0.00349 ** 
#p=0.001745

```


#Trans
```{r}

# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_trans)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df_trans[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.01750859

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.01750859,]


summary(lmer(quarkelt2 ~ quarkelt1 + time + anchor +
                           (1|respid), data = df_reduced_time))

#time        1.330e-01  2.219e-01 1.047e+02   0.599     0.55   
#p=0.275


```


#H7: Independent leaners more persuasive arguments than pure independents

#Environment

```{r}
df_partyintensity_1_2 <- subset(df_env, partyid_cat == 1 | partyid_cat == 2)

fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor + (1|respid), data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_6)

summary(fit_partyint_lean_est)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)
#0.01513448

df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.01513448,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint_lean))

#partyid_cat2   0.08963    0.19195 479.00000   0.467   0.6407 

#p=0.32035
```

#Immigration

```{r}
df_partyintensity_1_2 <- subset(df_imm, partyid_cat == 1 | partyid_cat == 2)

fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor + (1|respid), data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_6)

summary(fit_partyint_lean_est)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)
#0.02271617

df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.02271617,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint_lean))

#partyid_cat2   0.18935    0.12228  19.52912   1.549    0.138   

#p=0.069
```

#Trans

```{r}
df_partyintensity_1_2 <- subset(df_trans, partyid_cat == 1 | partyid_cat == 2)

fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor + (1|respid), data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_6)

summary(fit_partyint_lean_est)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)
#0.03187209

df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.03187209,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint_lean))

#partyid_cat2   0.06161    0.18366  31.04202   0.335    0.740


#p=0.37
```

#H8: Strong party identifiers less persuasive than weak dentifiers

#Environment
```{r}

library(lmerTest)


df_partyintensity_3_4 <- subset(df_env, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                anchor + (1|respid), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.02722381

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.02722381,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint))

#partyid_cat4   -0.06023    0.06499   77.60515  -0.927    0.357    

#p=0.1785

```


#Immigration
```{r}

library(lmerTest)

df_partyintensity_3_4 <- subset(df_imm, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                anchor + (1|respid), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.03758267

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.03758267,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint))

#partyid_cat4   -0.03181    0.06778   85.53238  -0.469 0.640067  
#p=0.3200335

```

#Trans
```{r}

library(lmerTest)


df_partyintensity_3_4 <- subset(df_trans, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                anchor + (1|respid), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  anchor + (1|respid), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.01312354

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.01312354,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + anchor +
                           (1|respid), data = df_reduced_partyint))

#partyid_cat4   -0.10040    0.07639   69.48396  -1.314    0.193  

#p=0.0965

```


#H9: Affective polarization is associated with lower persuasiveness

#Environment
```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_env)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df_env[as.numeric(rownames(cooks_h7)), ]

fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                 anchor + (1|respid), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.02375569

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.02375569,]

summary(lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_reduced_affpol))

#affpol        -0.03490    0.08988  103.20916  -0.388    0.699    

#p=0.3495
```

#Immigration
```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_imm)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df_imm[as.numeric(rownames(cooks_h7)), ]

fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                 anchor + (1|respid), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.02962644

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.02962644,]

summary(lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_reduced_affpol))

#affpol        -0.09388    0.09078  103.29981  -1.034    0.303    

#p=0.1515
```

#Trans
```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_trans)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df_trans[as.numeric(rownames(cooks_h7)), ]

fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                 anchor + (1|respid), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.01721789

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.01721789,]

summary(lmer(quarkelt2 ~ quarkelt1 + affpol + anchor +
                           (1|respid), data = df_reduced_affpol))

#affpol        -0.06877    0.10841   98.60457  -0.634    0.527   

#p=0.2635
```


#H10: Interest in politics is associated with greater persuasiveness


```{r}

fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_env)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df_env[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.02290826


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.02290826,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_reduced_pi))

#pol_intr_full 1.974e-01  1.081e-01 9.918e+01   1.827   0.0707 .  

#p=0.03535
```

#Immigration
```{r}
fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_imm)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df_imm[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.02920943


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.02920943,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_reduced_pi))

#pol_intr_full 9.905e-02  1.182e-01 1.124e+02   0.838   0.4038 

#P=0.2019
```


```{r}
fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_trans)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df_trans[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.01707163


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.01707163,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + anchor +
                           (1|respid), data = df_reduced_pi))

#pol_intr_full   -0.03433    0.14356  103.34753  -0.239 0.811497 

#p=0.4057485
```



# H11: Political knowledge is associated with greater persuasiveness
### Political Knowledge & Energy / Environment


```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_env)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df_env[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.02325964

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.02325964,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_reduced_pk))

#pol_know_avg 1.077e-01  9.656e-02 1.011e+02   1.115 0.267511  
 
#p=0.1337555
```

```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_imm)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df_imm[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.03042611

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.03042611,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_reduced_pk))

#pol_know_avg 1.236e-01  9.165e-02 1.072e+02   1.349   0.1802    


#p=0.0901
```


```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_trans)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df_trans[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.01827728

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.01827728,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + anchor +
                           (1|respid), data = df_reduced_pk))

#pol_know_avg   -0.04357    0.10132  101.26767  -0.430    0.668    
   
#p=0.334

```



#H12: Senders who mention specific facts are more persuasive

#Environment
```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_env) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df_env[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.02243652


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.02243652,]

summary(lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_reduced_fact))

#specific_fact1  1.469e-01  8.104e-02  8.967e+01   1.813   0.0732 .  

#p=0.0366

```


#Immigration
```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_imm) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df_imm[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.03020517


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.03020517,]

summary(lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_reduced_fact))

#specific_fact1   -0.11241    0.13309  128.67935  -0.845    0.400  

#p=0.200

```



#Trans
```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_trans) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df_trans[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.01782205


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.01782205,]

summary(lmer(quarkelt2 ~ quarkelt1 + specific_fact + anchor +
                           (1|respid), data = df_reduced_fact))

#specific_fact1   -0.01697    0.13072   87.46988  -0.130    0.897    

#p=0.0.4485

```

#Self Esteem

#Environment
```{r}
library(lmerTest)
### Self Esteem ###

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_env)

summary(fit_selfest)

cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df_env[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.02291956

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.02291956,]

summary(lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_reduced_selfest1))

#self_est      -0.02779    0.12184  141.34879  -0.228 0.819884     

#p=0.409942


```

#Immigration
```{r}
library(lmerTest)
### Self Esteem ###

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_imm)

cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df_imm[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.02995359

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.02995359,]

summary(lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_reduced_selfest1))

#self_est      -0.07229    0.11667  109.02922  -0.620  0.53679 

#p=0.268395


```

#Trans
```{r}
library(lmerTest)
### Self Esteem ###

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_trans)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df_trans[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.01728383

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.01728383,]

summary(lmer(quarkelt2 ~ quarkelt1 + self_est + anchor +
                           (1|respid), data = df_reduced_selfest1))

#self_est    6.267e-02  1.259e-01 1.040e+02   0.498  0.61976   

#p=0.30988


```


#Issue Attitude Extremity

#Environment
```{r}

fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_env)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df_env[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.02317104

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.02317104,]

summary(lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_reduced_attstrength))

#att_strength   -0.06606    0.08308   92.00980  -0.795    0.429   

#p = 0.2145
```


#Immigration
```{r}

fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_imm)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df_imm[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.03023909

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.03023909,]

summary(lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_reduced_attstrength))

#att_strength   -0.04870    0.09690  117.61699  -0.503  0.61617    

#p = 0.308085
```



#Trans
```{r}

fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_trans)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df_trans[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.01802647

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.01802647,]

summary(lmer(quarkelt2 ~ quarkelt1 + att_strength + anchor +
                           (1|respid), data = df_reduced_attstrength))

#aatt_strength   -0.05416    0.08523  102.19078  -0.635    0.527    

#p = 0.2635
```


#ISSUES COMBINED

# Calculations for 
# Table A.9.1: Results from Combined Analysis of Study 1 and Study 2

### Political Knowledge 
```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_polknow)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df2[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.120693

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.120693,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_pk))

#pol_know_avg  7.336e-02  5.384e-02  2.861e+02   1.363 0.174108    

#p=0.087054

```


#Interest in politics is associated with greater persuasiveness

```{r}

fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df2[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.1204611


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.1204611,]

summary(lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_pi))

#pol_intr_full  5.093e-02  6.876e-02  2.909e+02   0.741 0.459501    


#p=0.2297505 (0.459501/2)
```

#Need for cognition is associated with greater persuasion
```{r}
### Need for Cognition ###
fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df2[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_3)
summary(fit_nfc_est)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.1202881


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.1202881,]

summary(lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_nfc))

#nfc          1.217e-01  7.027e-02  2.901e+02   1.732 0.084345 .

#p=0.0421725 (0.084345/2)
```

#Senders who mention specific facts are more persuasive

```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df2[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.1186584


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.1186584,]

summary(lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_fact))

#specific_fact1  1.093e-01  6.171e-02  2.738e+02   1.771   0.0776 .  

#p=0.0388 (0.0776/2)
```

#Strong party identifiers less persuasive than weak dentifiers
```{r}

library(lmerTest)

#Create New Dataframe that includes only rows where df2$partyid_cat is 3 or 4

df_partyintensity_3_4 <- subset(df2, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.1459023

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.1459023,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint))

#partyid_cat4 -4.550e-02  3.956e-02  2.119e+02  -1.150   0.2513   

#p=0.12565

```


#Independent leaners more persuasive arguments than pure independents
```{r}
# Leaners better at persuading relative to pure independents

df_partyintensity_1_2 <- subset(df2, partyid_cat == 1 | partyid_cat == 2)


fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)


cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_6)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)
#0.1812557

df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.1812557,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint_lean))

#partyid_cat2  9.162e-02  9.292e-02  8.054e+01   0.986  0.32710    


#p=0.16355
```

#Affective polarization is associated with lower persuasiveness

```{r}
library(lme4)
### Affective Polarization ###

# Linear Analysis: Affective Polarization 
fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df2[as.numeric(rownames(cooks_h7)), ]


fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.1198802

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.1198802,]

summary(lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_affpol))

#affpol      -3.181e-02  5.409e-02  2.810e+02  -0.588 0.556946       

#p=0.278473
```

#Perspective taking ability is associated with greater persuasion

```{r}
library(lmerTest)
### Perspective Taking ###

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df2[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.1203202

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.1203202,]

summary(lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_persptak))

#persp_tak    1.630e-01  7.840e-02  2.578e+02   2.079 0.038649 *  

#p=0.0193245


```

#Senders who use personal appeals are more persuasive

```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df2[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_9)
summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.1195358

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.1195358,]


summary(lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_personal_rev))

#personal_rev1    0.24197    0.05745  322.26760   4.212 3.29e-05 ***

```


#Senders who highlight common ground are more persuasive

```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df2[as.numeric(rownames(cooks_h10)), ]


fit_cg_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_10)
summary(fit_cg_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_cg_est))


mean(cooks_h10$`cooks.distance(fit_cg_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_cg_est)`)
#0.118181

df_reduced_cg <- df_estimation_10[cooks_h10$`cooks.distance(fit_cg_est)` < 0.118181,]


summary(lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_cg))

#common_ground1  1.648e-01  3.792e-02  2.661e+02   4.346 1.97e-05 ***


```


# Long messages are more persuasive

```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df2[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.1186519

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.1186519,]


summary(lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_length))

#mlengthwords  4.724e-01  8.073e-02  3.132e+02   5.852 1.23e-08 ***




```


# Messages that took more time to write are more persuasive

```{r}

# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df2[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.1200053

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.1200053,]


summary(lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_time))

#time         3.184e-01  1.065e-01  2.839e+02   2.990  0.00303 **   
#p=0.001515

```

#Self Esteem
```{r}
library(lmerTest)
### Self Esteem ###

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_selfest)

cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df2[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.1198025

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.1198025,]

fit_selfest_1_cdr <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_selfest1)

summary(fit_selfest_1_cdr)

#self_est    -5.691e-02  6.785e-02  3.184e+02  -0.839 0.402223   

#p=0.2011115


```

#Issue Attitude Extremity
```{r}

fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_attstrength)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df2[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.1203288

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.1203288,]

summary(lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_attstrength))

#qtt_strength -5.565e-02  4.859e-02  2.775e+02  -1.145 0.253072 

#p = 0.126536
```


